<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h2>总价格:{{totalPrice}}</h2>
    </div>
</body>
<script src='../js/vue.js'></script>
<script>
    let app = new Vue({
        el: '#app',
        data: {
             msg:'hello vue.js',
             books: [
                 {id:110,name:'编程艺术',price:119},
                 {id:111,name:'代码大全',price:105},
                 {id:112,name:'深入计算机原理',price:98},
                 {id:113,name:'现代操作技术',price:87},
             ]
        },
        methods: {},
        computed: {
            totalPrice:function(){
                let result = 0
                for (let i = 0; i < this.books.length; i++) {
                    result += this.books[i].price;
                    
                }
                return result
            }
        }
    })
</script>
</html>